using System;
using System.IO;
using EnvDTE;
using Microsoft.WowAddonStudio.Services;
using Microsoft.WowAddonStudio.Tests.Common.Mocks;
using NUnit.Framework;

namespace Microsoft.WowAddonStudio.Lua.RuntimeService.Tests.WowBench
{
	public class WoWBenchTestBase
	{
		private readonly SimpleTestServiceLocator provider = new SimpleTestServiceLocator();
		protected readonly string wowBenchPath = Path.Combine(Environment.CurrentDirectory, @"..\..\..\Debug\Tools\WoWBench");
		protected readonly string savedPath = Environment.CurrentDirectory;

		/// <summary>
		/// Gets the provider.
		/// </summary>
		/// <value>The provider.</value>
		protected SimpleTestServiceLocator Provider
		{
			get { return provider; }
		}

		#region SetUp

		/// <summary>
		/// Tests the fixture set up.
		/// </summary>
		[TestFixtureSetUp]
		public virtual void TestFixtureSetUp()
		{
			SimpleTestServiceLocator.Register<DTE>(new MockDTE());
			SimpleTestServiceLocator.Register<IAddonStudioSettings>(new MockAddonStudioSettings(wowBenchPath));
		}

		/// <summary>
		/// Sets up.
		/// </summary>
		[SetUp]
		public virtual void SetUp()
		{
		}

		#endregion

		#region TearDown

		/// <summary>
		/// Tests the fixture tear down.
		/// </summary>
		[TestFixtureTearDown]
		public virtual void TestFixtureTearDown()
		{
			SimpleTestServiceLocator.Reset();
		}

		/// <summary>
		/// Tears down.
		/// </summary>
		[TearDown]
		public virtual void TearDown()
		{
		}

		#endregion

		/// <summary>
		/// Gets the DTE.
		/// </summary>
		/// <value>The DTE.</value>
		protected internal static DTE DTE
		{
			get { return SimpleTestServiceLocator.Get<DTE>(); }
		}

		/// <summary>
		/// Creates the mock property.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="key">The key.</param>
		/// <param name="value">The value.</param>
		/// <returns></returns>
		protected static MockProperty CreateMockProperty(Properties parent, string key, string value)
		{
			return new MockProperty(DTE, key, parent, value);
		}

	}
}